//
//  LCRegisterViewController.m
//  ZhuCeDenglu
//
//  Created by 吕超 on 16/5/17.
//  Copyright © 2016年 lc. All rights reserved.
//

#import "LCRegisterViewController.h"
#import "LCLoginViewController.h"

@interface LCRegisterViewController ()

@end

@implementation LCRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self SubTextFiled];
    self.view.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1];
    
    self.FaSongYanZhengMa.enabled = NO;
    // 第一个参数，接受消息的对象了（一般都是self）；谁观察接受消息就写在谁的地方
    // 第二个参数，接受消息之后要出发的事件
    // 第三个参数，通知的名字，也是通知的唯一标识；（通知中心可以发送很多通知，利用这个参数来区分不同的通知）
    // 第四个参数，一般是nill
    // 注册通知， 检测输入框的字的长度;系统post出得通知；
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeText:) name:UITextFieldTextDidChangeNotification object:nil];
}



- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}





-(void)changeText:(NSNotification *)sender{
    
    if (self.RegisterName.text.length >= 11) {
        self.FaSongYanZhengMa.enabled = YES;

        [self.FaSongYanZhengMa setTitleColor:[UIColor colorWithRed:40/ 255.0 green:187/255.0 blue:208/255.0 alpha:1] forState:UIControlStateNormal];

    }else{
        self.FaSongYanZhengMa.enabled = NO;
             [self.FaSongYanZhengMa setTitleColor:[UIColor colorWithRed:190/ 255.0 green:190/255.0 blue:190/255.0 alpha:1] forState:UIControlStateNormal];
    }
}


//注册按钮
- (IBAction)RegisterButton:(id)sender {
    
    self.blockString(self.RegisterName.text , self.RegisterPassword.text);

    [self.navigationController popToRootViewControllerAnimated:YES];
}




//去掉边框  加背景色
- (void)SubTextFiled{
    [_RegisterName setBorderStyle:UITextBorderStyleNone];
    _RegisterName.backgroundColor = [UIColor whiteColor];
    
    [_RegisterPassword setBorderStyle:UITextBorderStyleNone];
    _RegisterPassword.backgroundColor = [UIColor whiteColor];
    
    [_RegisterYZM setBorderStyle:UITextBorderStyleNone];
    _RegisterYZM.backgroundColor = [UIColor whiteColor];
}


- (void)dealloc{
    // 移除本控制器所有的通知；
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}



// 删除所有第一响应者  取消键盘
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
     [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
